<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <p2></p2>
    </div>

    <!-- 1.定义模板 -->
    <template id="parent">
        <div>
            <!-- 使用子组件 -->
            <c2 src1="images/1.png" msg="首页"></c2>
            <c2 src1="images/2.png" msg="搜索"></c2>
            <c2 src1="images/3.png" msg="热点"></c2>
            <c2 src1="images/4.png" msg="购物车"></c2>
            <c2 src1="images/5.png" msg="我的"></c2>
        </div>
    </template>

    <!-- 1.定义模板 -->
    <template id="child">
        <div style="width: 100px;float:left">
            <img :src="src1"/>
            <p>{{msg}}</p>
        </div>
    </template>
</body>
</html>
<script src="js/vue.min.js"></script>
<script>
    var app=new Vue({
        el:"#app",
        data:{},
        components:{
            "p2":{
                template:"#parent",
                components:{
                    "c2":{
                        template:"#child",
                        props:["src1","msg"]
                    }
                }

            }
        }
    });
</script>